import request from "@/utils/request";

// 查询库的元数据列表
export function listScckocMeta(query) {
  return request({
    // url: '/service-ry/scckocMeta/scckocMeta/list',
    url: "/service-input/v1/input/listRawTablesV5",
    method: "get",
    params: query,
  });
}
// 查询待清洗表数据
export function getlistClearTables(query) {
  return request({
    url: "/service-input/v1/input/listClearTablesV5",
    method: "get",
    params: query,
  });
}

// 查询库的元数据详细
export function getScckocMeta(id) {
  return request({
    url: "/service-ry/scckocMeta/scckocMeta/" + id,
    method: "get",
  });
}

// 新增库的元数据
export function addScckocMeta(data) {
  return request({
    url: "/service-ry/scckocMeta/scckocMeta",
    method: "post",
    data: data,
  });
}

// 清理元数据
export function clearScckocMeta(data) {
  return request({
    url: "/service-input/v1/input/startClearDb",
    method: "post",
    data: data,
  });
}

// 修改库的元数据
export function updateScckocMeta(data) {
  return request({
    url: "/service-ry/scckocMeta/scckocMeta",
    method: "put",
    data: data,
  });
}

// 删除库的元数据
export function delScckocMeta(id) {
  return request({
    url: "/service-ry/scckocMeta/scckocMeta/" + id,
    method: "delete",
  });
}

// 导出库的元数据
export function exportScckocMeta() {
  return request({
    url: "/service-ry/scckocMeta/scckocMeta/export",
    method: "get",
  });
}

// 获取关系库导入数据源列表
export function getDataSource() {
  return request({
    url: "/service-input/v1/input/getDataSourceV5",
    method: "get",
  });
}
// 获取关系库导入数据表列表
export function getTableInfoByDb(query) {
  return request({
    url: "/service-input/v1/input/getTableInfoByDbV5?db=" + query,
    method: "get",
  });
}
// 上传数据
export function uploadScckocMeta(formData) {
  console.log("接口处的formData", formData);
  return request({
    url: "/service-input/v1/input/uploadInputFileByFileTypeExV5",
    method: "post",
    headers: { "Content-Type": "multipart/form-data" },
    data: formData,
  });
}
export function autoClearScckocMeta(data) {
  return request({
    url: "/service-input/v1/input/excutePluginById",
    method: "post",
    data: data,
  });
}
// 获取文件导入数据表预名称
export function uploadInputFileByFileNameV5(id) {
  return request({
    url: "/service-input/v1/input/uploadInputFileByFileNameV5?db=" + id,
    method: "get",
  });
}

//获取模板表与主数据关系表_V5
export function getPrimaryRs() {
  return request({
    url: "/service-input/v1/input/getPrimaryRsV5",
    method: "get",
  });
}

export function publishClearTable(table1, table2) {
  let data = new FormData();
  data.append("src", table1);
  data.append("dest", table2);
  return request({
    url: "/service-input/v1/input/publishClearTable",
    method: "post",
    data: data,
    headers: {
      "Content-Type": "multipart/form-data;  charset=utf-8;",
    },
  });
}
//主数据
export function getListOthers(pageNum, pageSize) {
  return request({
    url: "/service-ry/scckocMeta/scckocMeta/getListOthers",
    method: "get",
    params: { pageNum, pageSize },
  });
}
//关系库表名
export function getfileName(id) {
  return request({
    url: "/service-ry/template/cfg/getfileName",
    method: "get",
    params: { id },
  });
}
